<?php

use think\facade\Route;

/** 后台管理接口 */
Route::group('admin/classes', function () {
    Route::get('list', 'list'); // 点播列表数据
    Route::get('create', 'create'); // 创建课程-页面
    Route::post('create', 'create'); // 创建课程-提交

    Route::group('<id>', function () {
        Route::get('edit', 'update'); // 修改课程-页面
        Route::put('$', 'update'); // 修改课程-提交
        Route::put('/edit/<field>', 'editField'); // 编辑指定字段（ps：如状态）
        Route::delete('$', 'delete'); // 删除课程-软删除
        Route::post('finished', 'finished'); // 完结课时
    })->pattern(['id' => '\d+', 'field' => '[a-zA-Z_]+']);
    Route::put('listing', 'listing');// 批量上架
    Route::put('disables', 'disables');// 批量禁用
    Route::delete('deletes/<ids>', 'deletes')->pattern(['ids' => '[\d,]+']);// 批量删除

})->prefix('\app\course\service\classes\admin\Classes@')->middleware(['adminRoute']);

/** 后台关联课程管理接口 */
Route::group('admin/classes/<classes_id>/link/', function () {
    // 关联课程列表
    Route::get('list', 'index');
    // 添加关联课程
    Route::post('create', 'create');
    // 移除关联的课程
    Route::delete('<id>$', 'delete')->pattern(['id' => '\d+']);

})->prefix('\app\course\service\classes\admin\ClassesLink@')->middleware(['adminRoute'])->pattern(['classes_id' => '\d+']);

/** 选择课程 */
Route::group('admin/classes/<classes_id>/choose', function () {
    // 获取课程列表--用于课程卡关联课程
    Route::get('courseList', 'getCourseList');
    // 获取课程分类
    Route::get('courseCategory/<pid>/list', 'getCourseCategory')->pattern(['pid' => '\d+']);
    // 获取课程分类
    Route::get('courseCategory/cascader', 'getCourseCategoryCascader');
})->prefix('\app\course\service\classes\admin\ClassesLink@')->middleware(['adminRoute'])->pattern(['classes_id' => '\d+']);

/** 班级课学员接口 */
Route::group('admin/classes/<course_id>/student', function () {
    // 获取学员列表
    Route::get('list', '@getStudentList')->append(['course_type' => 4]);
    Route::delete('<student_id>/delete', '@removeStudent')->append(['course_type' => 4])->pattern(['student_id' => '\d+']);
    // Route::get('<student_id>/info', '@learnInfo')->append(['course_type' => 1]);
})->prefix('\app\course\service\base\admin\CourseStudent')->middleware(['adminRoute'])->pattern(['course_id' => '\d+']);

/** 班级课订单 */
Route::group('admin/classes/order', function () {
    // 订单列表
    Route::get('list', 'index');
    // 订单导出
    Route::post('export', 'export');
})->prefix('\app\course\service\classes\admin\Order@')->middleware(['adminRoute']);
